package com.zk.iotgateway.util;

/**
 *
 * 内存查看工具类
 * @author:mn.m
 * @create 2019-06-10 上午 10:39
 **/
public final  class MemoryUtils {

    private MemoryUtils(){}

    public static long getUsedMemoryMB(){
        return (Runtime.getRuntime().totalMemory()-Runtime.getRuntime().freeMemory())/1024/1024;
    }

    public static long getFreeMemoryMB(){
        return Runtime.getRuntime().freeMemory()/1024/1024;
    }

    public static long getTotalMemoryMB(){
        return Runtime.getRuntime().totalMemory()/1024/1024;
    }

    public static String memoryInfo(){
        long freeMem = getFreeMemoryMB();
        long usedMem = getUsedMemoryMB();
        long totalMem = getTotalMemoryMB();
        return "Free memory " + freeMem + " Mb of " + totalMem + " Mb" +" used memory is "+usedMem +" Mb";
    }

}
